﻿using System.Drawing;
using System.Windows.Forms;

namespace PocketGPW
{
    public class DataGridNoteTextBoxColumn : DataGridTextBoxColumn
    {
        private DataGrid _dg;
        private StringFormat _sf;

        public DataGridNoteTextBoxColumn(DataGrid dg)
        {
            _dg = dg;

            _sf = new StringFormat();
            _sf.Alignment = StringAlignment.Center;
            _sf.LineAlignment = StringAlignment.Center;
        }

        protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
        {
            // tło
            g.FillRectangle(backBrush, bounds);

            // napis            
            object value = base.PropertyDescriptor.GetValue(source.List[rowNum]);
            bool noteExists = (value != null && value.ToString().Length > 0);
            g.DrawString(noteExists ? "N" : "", _dg.Font, foreBrush, bounds, _sf);
        }
    }
}
